(function () {
    var key = uuid();
    function uuid() {
        function S4() {
            return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
        }
        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
    }
    jQuery(document).ready(function() {
        $('#codeImage').attr('src','/admin/loginImageCode?key='+key);
        $('input[name="key"]').val(key);
        $.backstretch([
            "/assets/admin/pages/media/bg/1.jpg",
            "/assets/admin/pages/media/bg/2.jpg",
            "/assets/admin/pages/media/bg/3.jpg",
            "/assets/admin/pages/media/bg/4.jpg"
        ],{fade: 1000,duration: 8000});
        $('#codeImage').bind('click',function () {
            this.src = '/admin/loginImageCode?key='+key+'&t='+new Date()/1000;
            $('input[name="key"]').val(key);
        })
    });
}());
function checkForm() {
    var username=$('input[name="username"]').val(),
        password=$('input[name="password"]').val(),
        code=$('input[name="code"]').val();
    if( username == null || username ===""){
        $('.create-account > p').html("请输入用户名!");return false;
    }
    else if( password == null || password ===""){
        $('.create-account > p').html("请输入密码!");return false;
    }
    else if( code== null || code ===""){
        $('.create-account > p').html("请输入验证码!");return false;
    }
    return true;
}